package com.example.allshengmedical.system.activity;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.example.allshengmedical.R;
import com.example.allshengmedical.base.BaseActivity;
import com.example.allshengmedical.base.BaseApplication;
import com.example.allshengmedical.mainmenu.activity.MainMenuActivity;
import com.example.allshengmedical.system.presenter.OtherPresenter;
import com.example.allshengmedical.system.view.IOtherView;
import com.example.allshengmedical.util.ByAlert;

public class OtherActivity extends BaseActivity implements IOtherView,
		OnClickListener {

	private Button oemBtn, debugBtn, parametersBtn, fileBtn, internetBtn,
			exitBtn;
	private OtherPresenter otherPresenter;

	@Override
	protected int setcontent() {
		return R.layout.activity_system_other;
	}

	@Override
	protected void initView() {
		otherPresenter = new OtherPresenter(this);
		otherPresenter.initAppHead();
	}

	@Override
	protected void initData() {

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.oemBtn:
			otherPresenter.oemFunction();

			break;
		case R.id.debugBtn:
			otherPresenter.debugFunction();
			break;
		case R.id.parametersBtn:
			otherPresenter.parametersFunction();
			break;
		case R.id.fileBtn:
			otherPresenter.fileFunction();
			break;
		case R.id.internetBtn:
			otherPresenter.internetFunction();
			break;
		case R.id.exitBtn:
			otherPresenter.exitFunction();
			break;

		default:
			break;
		}

	}

	@Override
	public void initAppHead() {
		setActionBar();
		setSystemTime();

	}

	@Override
	public void oemFunction() {
		ByAlert.alert("1");

	}

	@Override
	public void debugFunction() {
		ByAlert.alert("2");

	}

	@Override
	public void parametersFunction() {
		ByAlert.alert("3");

	}

	@Override
	public void fileFunction() {
		ByAlert.alert("4");

	}

	@Override
	public void internetFunction() {
		ByAlert.alert("5");

	}

	@Override
	public void exitFunction() {
		BaseApplication.getInstance().exit();
	}

	// 获取当前时间的方法
	public void setSystemTime() {

		TextView date, fileName;
		date = BindView(R.id.date);
		fileName = BindView(R.id.file_name);

		// 获取系统时间
		SimpleDateFormat sdfDate = new SimpleDateFormat("MM dd,yyyy");
		date.setText(sdfDate.format(new Date()));

		// 文件路径置空
		fileName.setText("");

	}

	// 设置actionBar
	public void setActionBar() {
		Button leftfirstBtn, leftsecondBtn;
		TextView title;

		leftfirstBtn = BindView(R.id.leftfirst_btn);
		leftsecondBtn = BindView(R.id.leftsecond_btn);
		title = BindView(R.id.title);

		leftfirstBtn.setVisibility(View.VISIBLE);
		leftfirstBtn.setText(R.string.item_actionbar_back);
		leftsecondBtn.setVisibility(View.VISIBLE);
		leftsecondBtn.setText(R.string.item_actionbar_home);
		title.setText(R.string.maintenanceActivity_other);

		leftfirstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(OtherActivity.this,
						MaintenanceActivity.class);
				startActivity(intent);
				finish();

			}
		});
		leftsecondBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(OtherActivity.this,
						MainMenuActivity.class);
				startActivity(intent);
				finish();
			}
		});

	}

}
